package com.demo.utils;

/**
 * Created by byte2 on 2017-03-08.
 */
public class Pair<K, V> {
    private K key;
    private V value;

    public Pair() {
        this(null, null);
    }

    public Pair(K key, V value) {
        this.key = key;
        this.value = value;
    }

    public K getKey() {
        return this.key;
    }

    public void setKey(K key) {
        this.key = key;
    }

    public V getValue() {
        return this.value;
    }

    public void setValue(V value) {
        this.value = value;
    }

    public boolean equals(Pair<K, V> pair) {
        return pair != null ? ((key != null ? key.equals(pair.getKey()) : pair
                .getKey() == null) && (value != null ? value.equals(pair
                .getValue()) : pair.getValue() == null)) : false;
    }

    public Pair<K, V> clone() {
        return new Pair<K, V>(this.getKey(), this.getValue());
    }

    public String toString() {
        return String.format("[%s, %s]", String.valueOf(key),
                String.valueOf(value));
    }
}
